<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Step 2 :: SEO Toaster</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="pragma" content="no-cache" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <?php require_once 'includes/config.php'; ?>
  </head>
<body>
<div  id="seotoaster" class="installer_step2">
<div id="admineditwhat">Toasting websites Ingredients - Step two out of five</div>
<div id="content">    
    <!-- checking php version -->
    <div>Version PHP > 5.0.0</div>
    <div align="right"><?php echo  ($version) ? '<span class="green">Yes</span>' : '<span class="red">No</span>'; ?></div>
    <?php $error = ($version) ? false : true; ?>
    <!-- end checking php version -->
    <div class="separate"></div>

    <!-- checking extensions -->
    <div>Extensions:</div><div></div>
    <?php $exts = get_loaded_extensions();
    foreach (Config::$extensions as $needExt): ?>
    <div>&nbsp;&nbsp;<?php echo $needExt; ?></div>
        <?php if (in_array($needExt, $exts)): ?>
        <div align="right"><span class="green">Yes</span></div>
        <?php else: ?>
        <div align="right"><span class="red">Your need extension: <?php echo $needExt; ?></span></div> <?php $error = true; ?>
        <?php endif; ?>
    <?php endforeach; ?>
    <!-- end checking extensions -->
    <div class="separate"></div>
    
    <!-- checking directories -->
    <div style="width:98%;">The following directories must be writable:</div>
    <?php foreach (Config::$directories as $dir): ?>
        <div><?php echo preg_match('/application/i', $dir) ? '(into core folder) '.$dir : $dir; ?></div>
        <?php if (is_dir(Session::get('pathToRoot').$dir) || (preg_match('/application/i', $dir) && is_dir(Session::get('pathToCore').$dir))): ?>
            <?php if (is_writable(Session::get('pathToRoot').$dir) || (preg_match('/application/i', $dir) && is_writable(Session::get('pathToCore').$dir))): ?>
            <div align="right"><span class="green">Yes</span></div>
            <?php else: ?>
            <div align="right"><span class="red">This folder must be writable</span></div> <?php $error = true; ?>
            <?php endif; ?>
        <?php else: ?>
        <div align="right"><span class="red">You need to create this folder</span></div> <?php $error = true; ?>
        <?php endif; ?>
    <?php endforeach; ?>
    <!-- end checking directories -->
    <div class="separate"></div>
    
    <!-- checking files -->
    <div style="width:98%;">The following files must be writable:</div>
    <?php foreach (Config::$files as $file): ?>
       <?php if (preg_match('/application/i', $file)): $file = str_replace('{SITE_NAME}', ((isset($sitename) && !empty($sitename)) ? $siteName.'/' : ''), $file); $style = ' style="height:27px;"'; else: $style = ''; endif; ?>
    <div<?php echo $style; ?>><?php echo preg_match('/application/i', $file) ? '(into core folder) '.$file : $file; ?></div>
        <?php if (is_file(Session::get('pathToRoot').$file) || (preg_match('/application/i', $file) && is_file(Session::get('pathToCore').$file))): ?>
            <?php if (is_writable(Session::get('pathToRoot').$file) || (preg_match('/application/i', $file) && is_writable(Session::get('pathToCore').$file))): ?>
            <div align="right"<?php echo $style; ?>><span class="green">Yes</span></div>
            <?php else: ?>
            <div align="right"<?php echo $style; ?>><span class="red">This file must be writable</span></div> <?php $error = true; ?>
            <?php endif; ?>
        <?php else: ?>
        <div align="right"<?php echo $style; ?>><span class="red">You need to create this file</span></div> <?php $error = true; ?>
        <?php endif; ?>
    <?php endforeach; ?>

    <!-- end checking files -->
</div>

<?php if (!$error): ?>
<div class="navigation">
    <div class="left">
        <form action="index.php" method="post">
        <input type="hidden" name="step" value="1">
        <input type="submit" class="formsubmit" value="< Back">
    </form>
    </div>
    <div class="right">
    <form action="index.php" method="post">
        <input type="hidden" name="step" value="3">
        <input type="submit" class="formsubmit" value="Next >">
    </form>
    </div>
</div>
<?php else: ?>
<div class="navigation">
    <div class="right">
    <form action="index.php" method="post">
        <input type="hidden" name="step" value="2">
        <input type="submit" class="formsubmit" style="width:180px;" value="Check Again">
    </form>
    </div>
</div>
<?php endif; ?>
</div>